package ac.il.technion.cs236369.hw5.core.servlets.users;

import java.sql.Date;

import ac.il.technion.cs236369.hw5.core.entities.User;

public enum UserParameters {
	USER_LOGIN("userLogin") {
		public void saveParameterValue(User user, String value) {
			user.setLoginName(value);
		}
	},
	USER_PASSWORD("userPassword") {
		public void saveParameterValue(User user, String value) {
			user.setPassword(value);
		}
	},
	USER_FIRST_NAME("firstName") {
		public void saveParameterValue(User user, String value) {
			user.setFirstName(value);
		}
	},
	USER_LAST_NAME("lastName") {
		public void saveParameterValue(User user, String value) {
			user.setLastName(value);
		}
	},
	USER_PHONE_NUMBER("phoneNumber") {
		public void saveParameterValue(User user, String value) {
			user.setPhoneNumber(value);
		}
	},
	USER_ACTIVITY_STATUS("activityStatus") {
		public void saveParameterValue(User user, String value) {
			if (value == null || value.length() == 0)
				return;
			user.setActivityStatus(Date.valueOf(value));
		}
	};

	private String parameterName;

	private UserParameters(String name) {
		this.parameterName = name;
	}

	public String getName() {
		return parameterName;
	}

	abstract public void saveParameterValue(User user, String value);
}